package com.bzframework.pro.example.entity;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import org.hswebframework.ezorm.rdb.mapping.annotation.ColumnType;
import org.hswebframework.ezorm.rdb.mapping.annotation.DefaultValue;
import org.hswebframework.web.api.crud.entity.GenericEntity;
import org.hswebframework.web.api.crud.entity.RecordCreationEntity;
import org.hswebframework.web.api.crud.entity.RecordModifierEntity;
import org.hswebframework.web.crud.annotation.EnableEntityEvent;
import org.hswebframework.web.crud.generator.Generators;

import javax.persistence.Column;
import javax.persistence.Table;
import java.sql.JDBCType;

/**
 * @Author bingzhong
 * @Date 2024/11/20 15:04
 * @Description
 */
@Table(name = "example_entity")
@Getter
@Setter
@Schema(description = "示例实体类")
@EnableEntityEvent //开启实体类crud事件
public class ExampleEntity extends GenericEntity<String>
//实现这2个接口标记此实体类需要记录创建人修改人信息，在crud时会自动填充对应的信息。
        implements RecordCreationEntity, RecordModifierEntity {

    @Column(nullable = false)
    @Schema(description = "示例名称")
    private String name;

    @Column(nullable = false)
    @ColumnType(javaType = Integer.class, jdbcType = JDBCType.TINYINT)
    @Schema(description = "状态")
    private Integer status;

    //平台ID长度统一64,创建人不为空,不可修改
    @Column(length = 64, nullable = false, updatable = false)
    @Schema(description = "创建人ID", accessMode = Schema.AccessMode.READ_ONLY)
    private String creatorId;

    @Column(nullable = false, updatable = false)
    @DefaultValue(generator = Generators.CURRENT_TIME)
    @Schema(description = "创建时间", accessMode = Schema.AccessMode.READ_ONLY)
    private Long createTime;

    @Column(length = 64, nullable = false)
    @Schema(description = "修改人ID", accessMode = Schema.AccessMode.READ_ONLY)
    private String modifierId;

    @Column(nullable = false)
    @DefaultValue(generator = Generators.CURRENT_TIME)
    @Schema(description = "修改时间", accessMode = Schema.AccessMode.READ_ONLY)
    private Long modifyTime;


}
